package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * @description: 应用模板是否开通枚举
 * @Author: hongxiao
 * @date: 2019-06-05 15:41
 * @since v1.0
 */
@Getter
public enum AppModuleOpenEnum {
    /**
     * 枚举
     * 呼叫中心不在模板中心进行开通，所在模板中心不显示是否开通按钮及开通状态
     */
    OPENING(1, "enum.appModuleOpen.name.opening"),


    NOT_OPEN(0, "enum.appModuleOpen.name.not_open"),


    NOT_OPEN_HERE(-1, "enum.appModuleOpen.name.not_open_here"),


    UNKNOWN(404, "enum.appModuleOpen.name.unknown"),

    ;

    /**
     * 应用模板套餐类型
     */
    private int code;
    /**
     * 应用模板套餐类型名称
     */
    private String name;

    AppModuleOpenEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }
    public static AppModuleOpenEnum getByCode(Integer code) {
        if(code == null) {
            return UNKNOWN;
        }
        for (AppModuleOpenEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
